function openPopupWindow(theURL, width, height) {
    if (height == undefined && width == undefined){ 
        var newWind = eval("window.open('"+theURL+"','popupwin','width=640,height=500,scrollbars=yes,resizable=yes')")}
    else {
        var newWind = eval("window.open('"+theURL+"','popupwin','width="+width+",height="+height+",scrollbars=yes,resizable=yes')")}
    if (!newWind) {
        alert('Sorry, unable to open window at this time.')
        return;}
    if (!newWind.opener || newWind.opener == null) newWind.opener = window;    
    if (newWind) newWind.focus();
}

function setFocus(field) {
    var f = document.getElementById(field);
    
    if (f != null) {
        f.focus();
    }
}

function searchBoxFocusChanged(field) {
    var f = document.getElementById(field);
    
    if (f != null) {
        if (f.length == 0) {
            f.value = "Search Content...";
        }
    }
}

function searchBoxKeyDown(field) {
    var f = document.getElementById(field);
    
    if (f != null) {
        if (f.value == "Search Content...") {
            f.value = "";
        }
    }
}

function submitBasicSearchForm(form, field) {
    var frm = document.getElementById(form);
    
    var f = document.getElementById(field);
    
    if (f != null) {
        if (f.value == "Search Content...") {
            f.value = "";
        }
    }
    
    if (frm != null) {
        frm.submit();
    }
}

function submitAdvancedSearchForm(form) {
    var frm = document.getElementById(form);
    
    if (frm != null) {
        frm.submit();
    }
}

function resetAdvancedSearchForm() {
    var exclude = document.getElementById('exclude_words_textbox');
    var phrase = document.getElementById('phrase_textbox');
    var any = document.getElementById('any_words_textbox');
    var all = document.getElementById('all_words_textbox');
    var status = document.getElementById('status_select');
    var repository = document.getElementById('repository_textbox');
    var role = document.getElementById('role_select');
    var contributor = document.getElementById('contributor_textbox');
    
    if (exclude != null) {
        exclude.value = "";
    }
    
    if (phrase != null) {
        phrase.value = "";
    }
    
    if (any != null) {
        any.value = "";
    }
    
    if (all != null) {
        all.value = "";
    }
    
    if (status != null) {
        status.selectedIndex = 0;
    }
    
    if (repository != null) {
        repository.value = "";
    } 
    
    if (role != null) {
        role.selectedIndex = 0;
    } 
    
    if (contributor != null) {
        contributor.value = "";
    } 
}

function resetContentIdSearchForm() {
    var f = document.getElementById('content_identifier_textbox');
    
    if (f != null) {
        f.value = "";
    }
}

function resetMetadataIdSearchForm() {
    var f = document.getElementById('metadata_identifier_textbox');
    
    if (f != null) {
        f.value = "";
    }
}